//
//  PublishViewController.swift
//  SkylowAPP
//
//  Created by 王王凤丽 on 2024/9/20.
//

import UIKit
import Photos
import HXPhotoPicker
import Kingfisher
import zhPopupController

class PublishViewController: UIViewController {
    
    /// 相关配置
//    var config: PickerConfiguration = PhotoTools.getWXPickerConfig(isMoment: true)
    
    var config: PickerConfiguration = .init()
    
  
  
    
    
    
    
    /// 当前已选资源
    var selectedAssets: [PhotoAsset] = []
    var localAssetArray: [PhotoAsset] = []
    /// 是否选中的原图
    var isOriginal: Bool = false
    /// 相机拍摄的本地资源
    var localCameraAssetArray: [PhotoAsset] = []
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
//        ic_nav_more
        // Do any additional setup after loading the view.
        view.backgroundColor = UIColor.colorWith(hexString: "#F2F3F5")
        self.navigationItem.title = "Add"
        
//        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Pop1", style: .plain, target: self, action: #selector(showPop1))
        
       
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Pop2", style: .plain, target: self, action: #selector(showPop2))
//
//        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "头像", style: .plain, target: self, action: #selector(openAvatarPickerController))
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "发布", style: .plain, target: self, action: #selector(presentPickerController))
        
        
        
    }
    
    @objc func showPop1(){
        
    }
    
    @objc func showPop2(){
    }
    
    @objc func presentPickerController(){
        config.modalPresentationStyle = .fullScreen
        config.pickerPresentStyle = .present()
        config.setThemeColor(UIColor.colorWith(hexString: "#F15F79"))
        config.photoList.allowAddCamera = false
        config.photoList.cell.selectBox.style = .number
        
        let pickerController = PhotoPickerController(picker: config)
        pickerController.selectedAssetArray = selectedAssets
        pickerController.localCameraAssetArray = localCameraAssetArray
        pickerController.isOriginal = isOriginal
        
        pickerController.localAssetArray = localAssetArray
        pickerController.autoDismiss = false
        
        
        config.previewView.bottomView.isHiddenOriginalButton = true
        config.previewView.bottomView.isHiddenPreviewButton = true
        
        present(pickerController, animated: true, completion: nil)
    }
    
    //    @objc func presentPickerController(){
    //        config.modalPresentationStyle = .fullScreen
    //        config.pickerPresentStyle = .present()
    //        config.setThemeColor(UIColor.colorWith(hexString: "#F15F79"))
    //        config.photoList.allowAddCamera = false
    //        config.photoList.cell.selectBox.style = .number
    //
    //        let pickerController = PhotoPickerController(picker: config)
    ////        pickerController.selectedAssetArray = selectedAssets
    ////        pickerController.localCameraAssetArray = localCameraAssetArray
    ////        pickerController.isOriginal = isOriginal
    ////        pickerController.localAssetArray = localAssetArray
    //        pickerController.autoDismiss = false
    //        config.previewView.bottomView.isHiddenOriginalButton = true
    //        config.previewView.bottomView.isHiddenPreviewButton = true
    //
    //        present(pickerController, animated: true, completion: nil)
    //    }
   

}


